import base64
import pyperclip


def img_to_base64(img_path):
    with open(img_path, 'rb') as f:
        img_path = f.read()
        return str(base64.b64encode(img_path), encoding='utf-8')


if __name__ == '__main__':
    img_path = input("请输入图片路径：")
    pyperclip.copy(img_to_base64(img_path))
    print("base64编码已复制在剪切板")